package com.rx.service;

import java.util.List;
import java.util.Map;

import com.rx.dao.RoleDaoI;
import com.rx.dao.RoleDaoImpl;
import com.rx.entity.Role;

public class RoleServiceImpl implements RoleServiceI<Role> {
	private static RoleDaoI rdi=new RoleDaoImpl();
	
	@Override
	public boolean add(Role role) throws Exception {
		if(rdi.selectWhere(" and roleName='"+role.getRoleName()+"'").size()>0) {
			return false;
		}
		return rdi.insert(role);
	}

	@Override
	public boolean modify(Role t) throws Exception {
		
		return rdi.update(t);
	}

	@Override
	public boolean remove(int id) throws Exception {
		return rdi.delete(id);
	}

	@Override
	public List<Role> getAll() throws Exception {
		return rdi.selectAll();
	}

	@Override
	public List<Role> GetIdRole(int id) throws Exception {
		return rdi.selectWhere(" and id="+id );
	}

	@Override
	public Map<String, Object> getPageAll(int currentPage, int pagenum) throws Exception {
		return rdi.selectPage("", currentPage, pagenum);
	}

	
}
